<?php

namespace Luka\WindowBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
//use Symfony\Component\HttpFoundation\RedirectResponse;
//use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
//use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Luka\WindowBundle\Form\ContactType;
use Luka\NavigationBundle\Model\Item;

class HomeController extends WindowBaseController{

    public function indexAction()
    {
        //$locale = $this->get('session')->getLocale();
        //echo "locale: ".$locale."<br>";
/*
        $t = $this->get('translator')->trans('%name% on võimas', array('%name%' => 'ott'));
        echo $t;
*/
        return $this->render('LukaWindowBundle:Home:index.html.twig');
    }

    public function contactAction()
    {
        $form = $this->get('form.factory')->create(new ContactType());

        $request = $this->get('request');

        if ('POST' == $request->getMethod()) {
            $form->bindRequest($request);
            if ($form->isValid()) {
                $mailer = $this->get('mailer');
                // .. setup a message and send it
                // http://symfony.com/doc/current/cookbook/email.html

                $this->get('session')->setFlash('notice', 'Message sent!');

                return $this->redirect($this->generateUrl('_welcome'));
            }
        }

        return $this->render('LukaWindowBundle:Home:form.html.twig', array(
            'form' => $form->createView(),
        ));
    }
}
